//------------Sonic CD Amy Rose Script-------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

//-------Aliases-------//
#alias 64: TYPE_AMYROSE


sub ObjectMain
	Object.Priority=1
	if Player.XPos<Object.XPos
		Object.Direction=FACING_LEFT
	else
		Object.Direction=FACING_RIGHT
	endif
	switch Object.State
	case 0
		TempValue0=Object.Value6
		TempValue0/=10
		TempValue0+=11
		Object.Frame=TempValue0
		Object.Value6++
		if Object.Value6>139
			Object.Value6=0
		endif
		PlayerObjectCollision(C_TOUCH,-96,-360,96,360)
		if CheckResult==1
			Object.Value0=0
			Object.State=1
			Object.Frame=4
			Object.Value6=0
		endif
		break
	case 1
		Object.Value6++
		switch Object.Frame
		case 4
		case 6
			if Object.Value6==4
				Object.Value6=0
				Object.Frame++
			endif
			break
		case 5
		case 7
			if Object.Value6==3
				Object.Value6=0
				Object.Frame++
			endif
			break

		endswitch
		if Object.Frame>7
			Object.Frame=4
		endif
		if Object.Direction==FACING_RIGHT
			if Object.Value0<131072
				Object.Value0+=4096
			endif
			PlayerObjectCollision(C_TOUCH,-32,-360,4,360)
			if CheckResult==1
				if Player.Gravity==0
					if Player.Direction==Object.Direction
						PlayerObjectCollision(C_TOUCH,-32,-20,4,20)
						if CheckResult==1
#platform: Standard
							if Player.Animation==9
#endplatform
#platform: Mobile
							CheckEqual(Player.Animation,ANI_SPINDASH)
							TempValue0=CheckResult
							CheckEqual(Object[2].Type,TypeName[BlueShield])
							TempValue0|=CheckResult
							if TempValue0==1
#endplatform
								Object.State=8
								Object.Frame=9
								Object.Value1=-262144
								Object.Value5=1
								Object.Value0=-65536
							else
								Object.Value4=1
								Object.State=7
								Object.Frame=8
								Object.Value6=0
								Player.State=PlayerObject_Hugged
								PlayStageSfx(3,0)
#platform: Use_Haptics
								HapticEffect(52,0,0,0)
#endplatform
								if Stage.DebugMode==0
									SetAchievement(1,100)
								endif
							endif
						else
							Object.State=6
							Object.Frame=0
							Object.Value6=0
							Object.Value0=0
						endif
					else
						Object.State=6
						Object.Frame=0
						Object.Value6=0
						Object.Value0=0
					endif
				endif
			endif
			if Object.XPos<Object.Value3
				Object.XPos+=Object.Value0
			else
				Object.Value0=0
				Object.XPos=Object.Value3
				if Object.Value4==1
					Object.State=4
				else
					Object.State=2
					Object.Frame=0
					Object.Value6=0
				endif
			endif
		else
			if Object.Value0>-131072
				Object.Value0-=4096
			endif
			PlayerObjectCollision(C_TOUCH,-4,-360,32,360)
			if CheckResult==1
				if Player.Gravity==0
					if Player.Direction==Object.Direction
						PlayerObjectCollision(C_TOUCH,-32,-20,4,20)
						if CheckResult==1
#platform: Standard
							if Player.Animation==9
#endplatform
#platform: Mobile
							CheckEqual(Player.Animation,ANI_SPINDASH)
							TempValue0=CheckResult
							CheckEqual(Object[2].Type,TypeName[BlueShield])
							TempValue0|=CheckResult
							if TempValue0==1
#endplatform
								Object.State=8
								Object.Frame=9
								Object.Value1=-262144
								Object.Value5=1
								Object.Value0=65536
							else
								Object.Value4=1
								Object.State=7
								Object.Frame=8
								Object.Value6=0
								Player.State=PlayerObject_Hugged
								PlayStageSfx(3,0)
#platform: Use_Haptics
								HapticEffect(52,0,0,0)
#endplatform
								if Stage.DebugMode==0
									SetAchievement(1,100)
								endif
							endif
						else
							Object.State=6
							Object.Frame=0
							Object.Value6=0
							Object.Value0=0
						endif
					else
						Object.State=6
						Object.Frame=0
						Object.Value6=0
						Object.Value0=0
					endif
				endif
			endif
			if Object.XPos>Object.Value2
				Object.XPos+=Object.Value0
			else
				Object.Value0=0
				Object.XPos=Object.Value2
				if Object.Value4==1
					Object.State=5
				else
					Object.State=3
					Object.Frame=0
					Object.Value6=0
				endif
			endif
		endif
		break
	case 2
		Object.Value6++
		if Object.Value6==12
			Object.Value6=0
			Object.Frame++
		endif
		if Object.Frame>3
			Object.Frame=0
		endif
		if Object.Direction==FACING_LEFT
			Object.State=1
			Object.Frame=4
			Object.Value6=0
		endif
		break
	case 3
		Object.Value6++
		if Object.Value6==12
			Object.Value6=0
			Object.Frame++
		endif
		if Object.Frame>3
			Object.Frame=0
		endif
		if Object.Direction==FACING_RIGHT
			Object.State=1
			Object.Frame=4
			Object.Value6=0
		endif
		break
	case 4
		if Object.Value6<8
			Object.Frame=0
		else
			if Object.Value6>47
				if Object.Value5==0
					if Object.Value6<120
						Object.Value1=-262144
						Object.Value5=1
						Object.Frame=9
					else
						Object.Value6=0
					endif
				else
					if Object.Value1>0
						Object.Frame=0
					endif
				endif
			else
				TempValue0=Object.Value6
				TempValue0-=8
				TempValue0%=20
				TempValue0/=10
				Object.Frame=TempValue0
				Object.Frame+=9
			endif
		endif
		if Object.Value5==0
			if Object.Direction==FACING_LEFT
				Object.State=1
				Object.Frame=4
				Object.Value6=0
			endif
		endif
		Object.Value6++
		break
	case 5
		if Object.Value6<8
			Object.Frame=0
		else
			if Object.Value6>47
				if Object.Value5==0
					if Object.Value6<120
						Object.Value1=-262144
						Object.Value5=1
						Object.Frame=9
					else
						Object.Value6=0
					endif
				else
					if Object.Value1>0
						Object.Frame=0
					endif
				endif
			else
				TempValue0=Object.Value6
				TempValue0-=8
				TempValue0%=20
				TempValue0/=10
				Object.Frame=TempValue0
				Object.Frame+=9
			endif
		endif
		if Object.Value5==0
			if Object.Direction==FACING_RIGHT
				Object.State=1
				Object.Frame=4
				Object.Value6=0
			endif
		endif
		Object.Value6++
		break
	case 6
		Object.Value6++
		if Object.Value6==12
			Object.Value6=0
			Object.Frame++
		endif
		if Object.Frame>3
			Object.Frame=0
		endif
		PlayerObjectCollision(C_TOUCH,-4,-360,4,360)
		if CheckResult==0
			if Player.Gravity==0
				Object.State=1
				Object.Frame=4
				Object.Value6=0
			endif
		else
			if Player.Gravity==1
				Object.State=1
				Object.Frame=4
				Object.Value6=0
			endif
		endif
		break
	case 7
		Player.Speed=0
		Player.XVelocity=0
		Player.Direction=Object.Direction
		if Player.Animation==10
			Object.State=8
			Object.Frame=9
			Object.Value1=-262144
			Object.Value5=1
			if Object.Direction==FACING_RIGHT
				Object.Value0=-65536
			else
				Object.Value0=65536
			endif
		endif
		break
	case 8
		if Object.Value1>0
			Object.Frame=10
		endif
		if Object.Value0>0
			Object.Value0-=2048
		endif
		if Object.Value0<0
			Object.Value0+=2048
		endif
		Object.XPos+=Object.Value0
		if Object.Value5==0
			if Object.Value6==16
				Object.State=1
				Object.Frame=4
				Object.Value6=0
			else
				Object.Value6++
			endif
		endif
		if Object.XPos>Object.Value3
			Object.XPos=Object.Value3
		endif
		break

	endswitch
	Object.Value7++
	if Object.State==7
		if Object.Value7>15
			CreateTempObject(TypeName[LoveHeart],0,Object.XPos,Object.YPos)
			Object[TempObjectPos].iYPos-=6
			Object[TempObjectPos].InkEffect=2
			Object[TempObjectPos].Alpha=255
			Object.Value7=0
		endif
	else
		if Object.Value7>41
			CreateTempObject(TypeName[LoveHeart],0,Object.XPos,Object.YPos)
			Object[TempObjectPos].iYPos-=6
			Object[TempObjectPos].InkEffect=2
			Object[TempObjectPos].Alpha=255
			Object.Value7=0
		endif
	endif
	if Object.Value5==0
		ObjectTileGrip(0,0,19,0)
	else
		Object.Value1+=16384
		Object.YPos+=Object.Value1
		ObjectTileCollision(0,0,19,0)
		if CheckResult==1
			Object.Value1=0
			Object.Value5=0
		endif
	endif
	if Object.OutOfBounds==1
		Object.Priority=0
		Object.State=0
		Object.Value4=0
	endif
endsub


sub ObjectDraw
	DrawSpriteFX(Object.Frame,FX_FLIP,Object.XPos,Object.YPos)
endsub


sub ObjectStartup
	LoadSpriteSheet("R1/Objects.gif")
	ArrayPos0=32
	while ArrayPos0<1056
		if Object[ArrayPos0].Type==TypeName[AmyRose]
			if Stage.PlayerListPos==1
				Object[ArrayPos0].Type=TypeName[BlankObject]
			else
				if Options.GameMode==2
					Object[ArrayPos0].Type=TypeName[BlankObject]
				else
					Object[ArrayPos0].Value2=Object[ArrayPos0].XPos
					Object[ArrayPos0].Value2-=20971520
					Object[ArrayPos0].Value3=Object[ArrayPos0].XPos
					Object[ArrayPos0].Value3+=4194304
					Object[ArrayPos0].DrawOrder=4
				endif
			endif
		endif
		ArrayPos0++
	loop
	SpriteFrame(-11,-20,22,40,34,208)
	SpriteFrame(-11,-20,22,40,57,208)
	SpriteFrame(-11,-20,22,40,34,208)
	SpriteFrame(-11,-20,22,40,126,167)
	SpriteFrame(-15,-20,30,40,68,167)
	SpriteFrame(-10,-20,21,40,166,101)
	SpriteFrame(-13,-20,26,40,99,167)
	SpriteFrame(-10,-20,21,40,166,101)
	SpriteFrame(-12,-20,24,40,181,208)
	SpriteFrame(-13,-20,26,40,80,208)
	SpriteFrame(-12,-20,24,40,107,208)
	SpriteFrame(-12,-20,22,40,158,208)
	SpriteFrame(-12,-20,22,40,158,208)
	SpriteFrame(-12,-20,22,40,158,208)
	SpriteFrame(-12,-20,22,40,158,208)
	SpriteFrame(-12,-20,22,40,158,208)
	SpriteFrame(-14,-20,25,40,132,208)
	SpriteFrame(-14,-20,25,40,132,208)
	SpriteFrame(-14,-20,25,40,132,208)
	SpriteFrame(-12,-20,22,40,158,208)
	SpriteFrame(-12,-20,22,40,158,208)
	SpriteFrame(-12,-20,22,40,158,208)
	SpriteFrame(-14,-20,25,40,132,208)
	SpriteFrame(-14,-20,25,40,132,208)
	SpriteFrame(-14,-20,25,40,132,208)
endsub

sub RSDK
	LoadSpriteSheet("Global/Display.gif")
	SetEditorIcon(Icon0,SingleIcon,-16,-16,32,32,1,143)
endsub
